//
//  TableViewCell.m
//  滑动图片视觉差
//
//  Created by ios on 16/7/21.
//  Copyright © 2016年 ios. All rights reserved.
//

#import "TableViewCell.h"

@implementation TableViewCell



- (void)cellOnTableView:(UITableView *)tableView didScrollView:(UIView *)view
{
    // 将cell的frame转换成view的Frame(为了获取每个cell的Y值)
    CGRect rect = [tableView convertRect:self.frame toView:view];
    
    //所看到的每个CellY值(实时获取滚动的值)
    //以屏幕中心点为0点 获取能看到的每个Cell离中心点得值是多少
    float distanceCenter = CGRectGetHeight(view.frame)/2 - CGRectGetMinY(rect);
    
    // 获取图片超出cell高度部分，图片肯定要比cell大，否则不会有视觉差效果
    float difference = CGRectGetHeight(self.bigImage.frame) - CGRectGetHeight(self.frame);
    
    float imageMove = (distanceCenter / CGRectGetHeight(view.frame)) * difference;
    
    //旧的图片Frame
    CGRect imageRect = self.bigImage.frame;
    
    //移动
    imageRect.origin.y = imageMove - (difference/2);
    
    //新的图片Frame
    self.bigImage.frame = imageRect;
}




- (void)awakeFromNib {
    // Initialization code
    self.clipsToBounds = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
